package com.listener;

import java.io.File;

/**
 * @ClassName: Editor
 * @Description:
 * @Author Fly
 * @Date 2022/12/19 11:31
 */
public class Editor {

    public EventManager events;
    private File file;


    public Editor() {
        this.events = new EventManager("open", "save");
    }

    public void openFile(String filePath) {
        File file = new File(filePath);
        events.notify("open", file);
    }

    public void saveFile() throws Exception {
        if (file != null) {
            events.notify("save", file);
        } else {
            throw new Exception("Please open a file first.");
        }
    }


}
